package yf.mall.controller.api;

import com.github.pagehelper.PageHelper;
import com.yf.annotation.LoginUserId;
import com.yf.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yf.mall.entity.AccCardEntity;
import yf.mall.entity.CashApplyEntity;
import yf.mall.enums.CashApplyStatusEnum;
import yf.mall.service.CashApplyService;

import java.util.HashMap;
import java.util.List;

@RequestMapping("/api/cashApply")
@RestController
public class ApiCashApplyController {

    @Autowired
    private CashApplyService cashApplyService;

    /**
     * Long
     * 提现申请
     * @param userId
     * @param cashApplyEntity
     * @return
     */
    @RequestMapping("apply")
    public R apply(@LoginUserId Long userId, CashApplyEntity cashApplyEntity){
        this.cashApplyService.apply(userId,cashApplyEntity);
        return R.ok();
    }

    @RequestMapping("list")
    public R applyList(@LoginUserId Long userId,int page,int limit){
        PageHelper.startPage(page, limit).setOrderBy("crate_time desc");
        HashMap<String, Object> params = new HashMap<>();
        params.put("userId",userId);
        List<CashApplyEntity> cashApplyEntities = this.cashApplyService.queryList(params);
        return R.ok(cashApplyEntities);
    }


}
